package org.nidy.erp.controller;

import lombok.extern.slf4j.Slf4j;
import org.nidy.erp.pojo.ProduceSorting;
import org.nidy.erp.service.IProduceService;
import org.nidy.erp.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/produceSorting")
@CrossOrigin(origins = "*", maxAge = 3600)
public class ProduceController {
    @Autowired
    private IProduceService produceService;
    public ProduceController(IProduceService produceService)
    {
        this.produceService = produceService;
    }
    @GetMapping
    public ResponseResult getProduceSortingBoxNum(ProduceSorting produceSorting)
    {
        ProduceSorting produceSortingBoxNum = produceService.getProduceSortingBoxNum(produceSorting);
        log.info("获取条码信息:{}", produceSorting);
        log.info("获取条码信息返回结果:{}", produceSortingBoxNum);
        if (produceSortingBoxNum != null) {
            return ResponseResult.success(produceSortingBoxNum);
        } else {
            return ResponseResult.error("条码不存在"+produceSorting.getBarCode());
        }

    }
}
